<template>
  <view id="materialEdit">
		<view class="nav-box">
			<view class="nav-box-text">
				<image src="@/static/img/home/person.png" class="person"></image>
				<view class="welcome" v-if="roleStatus == 'sample'">
					<view><text>姓名：{{userInfos.nickName}}</text></view>
					<view><text>单位：{{userInfos.deptName}}</text></view>
				</view>
				<view class="welcome" v-else-if="roleStatus == 'audit'">
					<view><text>姓名：{{userInfos.nickName}}</text></view>
					<view><text>单位：{{userInfos.deptName}}</text></view>
				</view>
				<view class="welcome" v-else>
					<view><text>姓名：{{userInfos.nickName}}</text></view>
					<view><text>单位：{{userInfos.deptName}}</text></view>
				</view>
			</view>
		</view>
		<view class="project">
			<text>{{projectInfo.name}}</text>
		</view>
		<view class="uni-list">
			<uni-forms ref="form" :rules="rules" :modelValue="form">
																						<!-- form.pics.length==0?'hinde' -->
				<uni-forms-item label="巡检图片" name="pics" :class="pageStatus=='2'?'detail':''" :id="pageStatus=='2' && form.pics.length==0?'hinde':''">
					<uni-group>
						<uni-file-picker 
							v-model="form.pics" 
							limit="9"
							:auto-upload="false"
							:del-icon="pageStatus!='2'"
							:disabled="pageStatus=='2'"
							@delete="(e)=>{return delets(e,'img')}"
							@select="e=>{return fileUpload(e, 'photo')}"
						></uni-file-picker>
					</uni-group>
				</uni-forms-item>
				<uni-forms-item label="巡检部位" name="locationName" :required="pageStatus!='2'">
					<uni-easyinput :type="pageStatus=='2'?'textarea':''" :disabled="pageStatus=='2'" v-model="form.locationName" :inputBorder="false" :maxlength="100" placeholder="请输入" />
				</uni-forms-item>
				<uni-forms-item label="问题等级" name="troubleLevel" :required="pageStatus!='2'">
					<uni-group>
						<uni-data-checkbox :disabled="pageStatus=='2'" v-model="form.troubleLevel" :localdata="troubleOption"></uni-data-checkbox>
					</uni-group>
				</uni-forms-item>
				<uni-forms-item label="巡检描述" name="troubleDesc" :required="pageStatus!='2'">
					<uni-easyinput type="textarea" autoHeight :disabled="pageStatus=='2'" v-model="form.troubleDesc" :inputBorder="false" :maxlength="100" placeholder="请输入" />
				</uni-forms-item>
				<uni-forms-item label="整改期限" name="deadline" :required="pageStatus!='2'">
					<uni-datetime-picker :disabled="pageStatus=='2'" v-model="form.deadline" :border="false" type="date" />
				</uni-forms-item>
				
				<uni-list-item name="users">
					<template v-slot:header><text class="slot-box"><text class="is-required">{{pageStatus!='2'?'*':''}}</text>责任人</text></template>
					<template v-slot:body><text style="width: 0;"></text></template>
					<template v-slot:footer>
						<view class="tree-select" @click="pageStatus=='2'?'':$refs.leadertree._show()">
							{{ form.users.length>0?form.users.map(item=>{return item.userName}).join():'请选择' }}
						</view>
					</template>
				</uni-list-item>
				<uni-forms-item label="整改措施" name="measure">
					<uni-easyinput :disabled="pageStatus=='2'" v-model="form.measure" :maxlength="100" :inputBorder="false" type="textarea" placeholder="请输入" />
				</uni-forms-item>
				<uni-forms-item label="附件" name="files">
					<button type="primary" v-if="pageStatus!='2'" size="mini" @click="upload(0)" class="upbtn">附件上传</button>
				    <view class="fileList">
				    	<view v-for="(item,index) in form.files" @tap="down(item.url,item.name)" class="fileItem" :key="index">
				    		<text>{{item.name}}</text>
							<icon type="clear" v-if="pageStatus!='2'" size="14" @tap="deletFile('add',item)"/>
				    	</view>
				    </view>
				</uni-forms-item>
				<!-- 详情审批 -->
				<div class="radio">
					 <uni-forms-item label="处理" v-if="canAudit==true || canReply==true">
					 	<radio-group v-model="back" @change="changeHand">
					 		 <label v-if="canAudit==true"><radio value="0" />退回</label>
					 		 <label v-if="canAudit==true"><radio value="1" checked="true" />通过</label>
					 		 <label v-if="canReply==true"><radio value="2" />回复</label>
					 	</radio-group>
					 </uni-forms-item>
				</div>
				<!-- v-if="back!=null" 判断是否显示处理表单 -->
				<div v-if="canAudit==true || canReply==true">
					 <uni-forms-item label="图片上传" name="pics">
					 	<uni-group>
					 		<uni-file-picker 
					 				v-model="checkform.pic" 
					 				limit="9"
					 				@select="e=>{return detailUpload(e, 'photo')}"
					 			></uni-file-picker>
					 		</uni-group>
					 	</uni-forms-item>
					 	<uni-forms-item label="附件" name="file">
					 		<button type="primary" size="mini" @click="upload(1)" class="upbtn">附件上传</button>
					 		<view class="fileList">
					 			<view v-for="(item,index) in checkform.file" class="fileItem" :key="index">
					 				<text>{{item.name}}</text>
					 				<icon type="clear" size="14" @tap="deletFile('detail',item)"/>
					 			</view>
					 		</view>
					 	</uni-forms-item>
					 	<uni-forms-item label="整改描述" name="remark">
					 		<uni-easyinput v-model="checkform.remark" :maxlength="100" :inputBorder="false" type="textarea" placeholder="请输入" />
					 	</uni-forms-item>
					 
					 <view class="handleBtns">
					 	<button type="primary" size="mini" @click="submitHandle">提交</button>
					 </view>
				</div>
				<!-- 巡检历史记录 -->
				<view v-if="pageStatus=='2'">
					<view class="title">巡检整改审批记录</view>
					<uni-table class="tables" stripe emptyText="暂无更多数据">
						<uni-tr>
							<uni-th width="70">创建人</uni-th>
							<uni-th width="100">备注</uni-th>
							<uni-th>图片</uni-th>
							<uni-th>附件</uni-th>
						</uni-tr>
						<uni-tr v-for="item in table" :key="item.id">
							<uni-td>{{item.createByName}}</uni-td>
							<uni-td>{{item.remark}}</uni-td>
							<uni-td>
								<template>
									<view v-for="(res,index) in item.pics" :key="index">
										<image @tap="preView(res.url)" :src="res.url"></image>
									</view>
								</template>
							</uni-td>
							<uni-td>
								<template>
									<view class="name" v-for="(res,index) in item.files" :key="index" @tap="down(res.url,res.realName)">{{res.realName}}</view>
								</template>
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
			</uni-forms>
		    <!-- <view class="handleBtns" v-if="pageStatus=='2'">
		    	<button type="warn" size="mini" v-if="canAudit==true" @click="handleClick(0)">退回</button>
				<button type="primary" size="mini" v-if="canAudit==true" @click="handleClick(1)">通过</button>
				<button type="primary" size="mini" v-if="canReply==true" @click="handleClick(1)">回复</button>
		    </view> -->
		</view>
		
		<view style="height: 60px;"></view>
		<view class="bottom-nav" v-if="pageStatus!='2'">
			<button type="primary" :loading="loading" size="mini" class="btn" @click="save(0)" :disabled="Btn">保存</button>
			<button type="primary" :loading="loading" size="mini" class="btn" @click="save(1)" :disabled="Btn">提交</button>
		</view>
		<!-- 遮罩层 -->
		<fui-backdrop :show="showFul" closable @click="showFul=false">
			<image :src="preUrl" mode=""></image>
		</fui-backdrop>
		<!-- 详情处理抽屉 -->
		<!-- <uni-drawer ref="showRights" mode="right" :mask-click="true" :width="300">
		    <scroll-view style="height: 100%;" scroll-y="true">
		        <view class="uni-list">
		             <uni-forms ref="checkform" :modelValue="checkform">
		                	<uni-forms-item label="图片上传" name="pics">
		                		<uni-group>
		                			<uni-file-picker 
		                					v-model="checkform.pics" 
		                					limit="9"
											@select="e=>{return detailUpload(e, 'photo')}"
		                				></uni-file-picker>
		                			</uni-group>
		                		</uni-forms-item>
		                		<uni-forms-item label="附件" name="file">
									<button type="primary" size="default" @click="upload(1)" class="upbtn">附件上传</button>
		                			<view class="fileList">
		                				<view v-for="(item,index) in checkform.file" class="fileItem" :key="index">
		                					<text>{{item.name}}</text>
		                					<icon type="clear" size="14" @tap="deletFile('detail',item)"/>
		                				</view>
		                			</view>
		                		</uni-forms-item>
		                		<uni-forms-item label="整改描述" name="remark">
		                			<uni-easyinput v-model="checkform.remark" :maxlength="100" :inputBorder="false" type="textarea" placeholder="请输入" />
		                		</uni-forms-item>
		                	</uni-forms>
							<view class="handleBtns">
								<button type="warn" size="mini" @click="$refs.showRights.close()">取消</button>
								<button type="primary" size="mini" @click="submitHandle">提交</button>
							</view>
		                </view>
		            </scroll-view>
		        </uni-drawer> -->
		<!-- 分部分项树 -->
		<!-- <tki-tree ref="optiontree" :range="optionTree" confirmColor="#4e8af7" @confirm="optionTreeSelect" @cancel="optionTreeCancel" /> -->
		<!-- 责任人树 -->
		<tki-tree ref="leadertree" :range="personTree"  confirmColor="#4e8af7" :multiple="true" @confirm="personTreeSelect" @cancel="personTreeCancel" :selectParent="false" />
		<!-- 抄送人树 -->
		<tki-tree ref="copytree" :range="personTree" confirmColor="#4e8af7" :multiple="true" @confirm="copyTreeSelect" @cancel="copyTreeCancel" />
		<!-- 组织树 -->
		<tki-tree ref="depttree" :range="deptTree" confirmColor="#4e8af7" @confirm="deptTreeSelect" @cancel="deptTreeCancel" />
		  <l-file
			  ref="lFile"
			  @up-success="fileSuccess"
		  ></l-file>
  </view>
</template>

<script>
import {mapState} from 'vuex'
import {imgUpload,fileUpload,getPerson,addCheck,updateCheck,findDetail,handleCheck,findHistory} from '../../api/inspection/index.js'
import {downFile} from '@/common/urlDownLoad.js'
import {fileUrl} from '@/common/urlConfig.js'
export default {
  data() {
    return {
		Btn:false,
		 fileState:0,//是新增编辑附件上传还是详情处理附件上传，0为新增编辑，1为详情
		tables:[],
		showFul:false,//遮罩层
		preUrl:'',
		userInfos:{
			nickName:'',
			deptName:'',
		},
		pageStatus:'0',//新增编辑详情状态值
		table:[],//巡检历史记录
		checkId:'',//巡检id
		canReply:false,//是否可见回复按钮
		canAudit:false,//是否可见审核按钮
		handState:0,//0为回退，1为通过
			roleStatus: 'company',
			// 表单提交loading
			loading: false,
			// 表单
			form: {
				pics:[],
				locationName:'',
				troubleLevel:1,
				troubleDesc:'',
				deadline:'',
				users:[],
				measure:'',
				files:[]
			},
			checkform: {
				pic:[],
				file:[],
				remark: ''
			},
			// 图片上传
			photos: [],
			// 附件上传
			files: [],
			// 问题等级选项
			troubleOption: [
				{ text: '普通', value: 1 },
				{ text: '中等', value: 2 },
				{ text: '严重', value: 3 }
			],
			back:'1',
			backOption:[
				{ text: '退回', value: 0 },
				{ text: '通过', value: 1 },
				{ text: '回复', value: 2 }
			],
			// 回复类型选项
			flowOption: [
				{ text: '单个回复', value: 0 },
				{ text: '多个回复', value: -1 },
			],
			// 分部分项树
			optionTree: [
				{ id: 1, label: '赛迪', children: [ { id: 11, label: '张三' }, { id: 12, label: '李四' }, { id: 13, label: '王五' }] },
			],
			// 人员树
			personTree: [
				// { id: 1, label: '赛迪', children: [ { id: 11, label: '张三' }, { id: 12, label: '李四' }, { id: 13, label: '王五' }] },
			],
			// 组织树
			deptTree: [
				{ id: 1, label: '赛迪', children: [ { id: 11, label: '张三' }, { id: 12, label: '李四' }, { id: 13, label: '王五' }] },
			],
			// 验证
			rules: {
				inspectionPics: {
					rules: [{ required: true, errorMessage: '请上传图片' }]
				},
				troubleLevel:{
					rules: [{ required: true, errorMessage: '请选择问题等级' }]
				},
				locationName: {
					rules: [{ required: true, errorMessage: '请输入巡检部位' }]
				},
				deadline: {
					rules: [{ required: true, errorMessage: '请选择整改时间' }]
				},
				troubleDesc:{
					rules: [{ required: true, errorMessage: '请选输入巡检描述' }]
				}
			}
    }
  },
  computed:{
	 ...mapState(['projectInfo'])
  },
  onLoad(e) {
	  this.form.users=[]
	  this.form.pics=[]
	  this.form.files=[]
	  this.checkform.pics=[]
	  this.checkform.file=[]
	  this.getPersons()//查询人员列表
	  //接收路径传值
	  let datas=JSON.parse(e.obj)
	  this.pageStatus=datas.status
	  if(datas.id==''){
		    this.checkId=''
	  }else{
		  this.checkId=datas.id
		  this.form.id=datas.id
		  this.getDetail(datas.id)
	  }
	
	uni.getStorage({
			key: 'roleStatus',
			success: res=> {
				this.roleStatus = res.data
			}
	})
	uni.getStorage({
			key: 'userInfo',
			success: res=> {
				this.userInfos.nickName=res.data.nickName
				this.userInfos.deptName=res.data.dept.deptName
			}
	})
	this.historyList()
  },

  onReady() {
    uni.getStorage({
    	key: 'roleStatus',
    	success: res=> {
    		this.roleStatus = res.data
    	}
    })
	
	
  },
  methods: {
	  //处理选择值
	  changeHand(e){
		  this.back=Number(e.detail.value)
	  },
	  //删除附件
	  deletFile(type,item){
		  if(type=='add'){
			  let index=this.form.files.indexOf(item)
			  this.form.files.splice(index,1)
		  }else if(type=='detail'){
			  let index=this.checkform.file.indexOf(item)
			  this.checkform.file.splice(index,1)
		  }
	  },
	  //附件上传
	  fileSuccess(e){
		  if(e.statusCode==200){
			  //新增编辑
			  if(this.fileState==0){
				  this.form.files.push({
				  	fileID:e.data.id,
				  	url:e.data.url,
				  	name:e.data.realName
				  })
			  }else{
				  this.checkform.file.push({
				  	fileID:e.data.id,
				  	url:e.data.url,
				  	name:e.data.realName
				  })
			  }
			  
		  }else{
			  uni.showToast({
			  	title:e.msg,
				icon:'error'
			  })
		  }
	  },
	  //上传文件打开按钮
	  upload(e){
		  this.fileState=e
		  let isTrue=true
		  
		  if(e==0 ){
			  if(this.form.files.length<5){
				 isTrue=true 
			  }else{
				  isTrue=false
			  }
		  }else if(e==1){
			  if(this.checkform.file.length<5){
			  		isTrue=true 
			  }else{
			  		isTrue=false
			  }
		  }
		if(isTrue==true) {
			this.$refs.lFile.upload({
			      // #ifdef APP-PLUS
			      //（app端必传）nvue页面使用时请查阅nvue获取当前webview的api，当前示例为vue窗口
			      currentWebview: this.$mp.page.$getAppWebview(),
			      // #endif
			      //替换为你的上传接口地址
			      url: fileUrl,
			      // 服务端接收附件的key
			      name: 'file', 
			      //根据你接口需求自定义 (优先不传content-type,安卓端无法收到参数再传)
			      header: {
			          'Authorization': uni.getStorageSync('token'),
			      },
			  
			      // 限制选择附件的大小上限，默认10M
			      maxSize: 14,
			  
			      // 若需要在body单独添加附件名或附件大小如下方式传入组件：
			      // addName: '后端要的附件名称字段key,此处请勿写name的同值如(file)，会覆盖name',
			      // addSize: '后端要的附件大小字段key'
			  
			      // body参数直接写key,value,如：
			      // date: '2020-1-1',
			      // key2: 'value2',
			  });
			// appChooseFile().then(path => { 
			  
			//  })
		}else{
			uni.showToast({
				title:'最多允许上传5个附件',
				icon:'error'
			})
		}
		  
		  
	  },
	  //图片预览
	  preView(url){
		// this.preUrl=url
		// this.showFul=true
		uni.previewImage({
		            urls: [url],
		            
		        });
	  },
	  //下载附件
	  down(url,name){
		  downFile(url,name)
	  },
	  //巡检历史记录
	  historyList(){
		  if(this.checkId!=''){
			  findHistory(this.checkId).then(res=>{
			  			  if(res.code==200){
			  				  this.table=res.rows
			  			  }
			  })
		  } 
	  },
	  //删除文件图片
	  delets(e,type){
		  if(type=='img'){
			  let index=this.form.pics.indexOf(e.tempFile)
			  this.form.pics.splice(index,1)
		  }else if(type=='file'){
			  let index=this.form.files.indexOf(e.tempFile)
			  this.form.files.splice(index,1)
		  }
	  },
	  //打开详情处理
	  handleClick(e){
		  this.checkform.pic=[]
		  this.checkform.file=[]
		  this.checkform.remark=''
		  this.handState=e
		  this.back=null
		 this.$refs.showRights.open();
	  },
	  //提交详情处理
	  submitHandle(){
		  let state=this.back==0?0:1
		 handleCheck(this.checkId,this.handleImgFile(this.checkform.pic),this.checkform.remark,this.handleImgFile(this.checkform.file),state).then(res=>{
			 if(res.code==200){
				 uni.showToast({
				 	title:'提交成功',
					icon:'success'
				 })
				 // this.$refs.showRights.close();
				 uni.navigateTo({
				 	url:'./index'
				 })
			 }else{
				 uni.showToast({
				 	title:res.msg,
				 	icon:'error'
				 })
			 }
		 })
	  },
	  
	  // 详情文件上传成功触发
	  detailUpload(e, type) {
		  console.log('123')

	  	e.tempFilePaths.forEach(res=>{
	  		if(type=='photo'){
	  			imgUpload(res).then(item=>{
	  				let datas=JSON.parse(item)
	  				if(datas.code==200){
	  					uni.showToast({
	  						title:'图片上传成功'
	  					})
	  					this.checkform.pic.push({
	  						fileID:datas.data.id,
	  						url:datas.data.url
	  					})
	  					
	  				}else{
	  					uni.showToast({
	  						title:datas.msg,
	  					})
	  				}
	  			})
	  			
	  		}else if(type=='file'){
	  			fileUpload(res).then(item=>{
	  				let datas=JSON.parse(item)
	  				if(datas.code==200){
	  					uni.showToast({
	  						title:'文件上传成功'
	  					})
	  					this.checkform.file.push({
	  						fileID:datas.data.id,
	  						url:datas.data.url
	  					})
	  				}else{
	  					uni.showToast({
	  						title:item.msg,
	  					})
	  				}
	  			})
	  		}
	  		
	  	})
	  	
	  },
	  //根据id查询姓名
	  findUseranme(id){
		  let userName=''
		  this.personTree.forEach(item=>{
			  if(item.children!=null && item.children.length>0){
				  item.children.forEach(res=>{
					  if(id==res.id){
						  userName=res.label
					  }
				  })
			  }
		  })
		  return userName;
	  },
	  //查找责任人是否选中
	  findChecked(id){
		  let isChecked=false
		  this.form.users.forEach(res=>{
			  if(res.userId==id){
				  isChecked=true
			  }
		  })
		  return isChecked
	  },
	  //查找单位下人员
	  findChildren(data){
		return data.map(res=>{
			res.checked= this.findChecked(res.id)
			return res
		 })
	  },
	  //查询详情
	  getDetail(id){
		  findDetail(id).then(item=>{
		  	if(item.code==200){
				this.canAudit=item.data.canAudit
				this.canReply=item.data.canReply
		  		this.form.locationName=item.data.locationName
		  		this.form.troubleLevel=item.data.troubleLevel
		  		this.form.troubleDesc=item.data.troubleDesc
		  		this.form.deadline=item.data.deadline
				if(item.data.users!=null){
					this.form.users=item.data.users.map(res=>{
						return {
							userId:res,
							userName:this.findUseranme(res)
						}
					})
				}
				this.personTree=this.personTree.map(item=>{
					item.children=this.findChildren(item.children)
					return item
				})
				
				// this.personTree=this.personTree.map(item=>{
				// 	 item.checked=this.findChecked(item.id)
				// 	return item
				// })
		  		this.form.measure=item.data.measure
				this.form.id=item.data.id
		  		if(item.data.pics!=null){
		  			this.form.pics=item.data.pics.map(items=>{return {fileID:items.id,extname:items.fileSuffix,name:items.realName,url:items.url}})
		  		}
		  		if(item.data.files!=null){
		  			this.form.files=item.data.files.map(items=>{return {fileID:items.id,extname:items.fileSuffix,name:items.realName,url:items.url}})
		  		}
		  	}else{
		  		uni.showToast({
		  			title:item.msg,
		  			icon:'error'
		  		})
		  	}
		  })
	  },
	  //监听新增或编辑状态
	  //查询责任人
	  getPersons(){
		getPerson(this.projectInfo.id).then(res=>{
			if(res.code==200){
				//单位下有人才展示单位及人员
				let arrays=res.rows.map(item=>{
					return {
						id:item.id,
						label:item.deptName,
						children:item.person.map(items=>{
							return {
								id:items.personId,
								label:items.nickName
							}
						})
					}
					
				})
				this.personTree=arrays.filter((res)=>{
					if(res.children!=null && res.children.length>0){
						return res
					}
				})
			}
			
		}) 
	  },
		// 文件上传成功触发 
		fileUpload(e, type) {
			var that = this
			that.Btn = true
			console.log("12")
			e.tempFilePaths.forEach(res=>{
				if(type=='photo'){
					imgUpload(res).then(item=>{
						let datas=JSON.parse(item)
						if(datas.code==200){
							uni.showToast({
								title:'图片上传成功'
							})
							this.form.pics.push({
								fileID:datas.data.id,
								url:datas.data.url
							})
							that.Btn = false
						}else{
							uni.showToast({
								title:datas.msg,
							})
						}
					})
					
				}else if(type=='files'){
					fileUpload(res).then(item=>{
						let datas=JSON.parse(item)
						if(datas.code==200){
							uni.showToast({
								title:'文件上传成功'
							})
							this.form.files.push({
								fileID:datas.data.id,
								url:datas.data.url
							})
							that.Btn = false
						}else{
							uni.showToast({
								title:item.msg,
							})
						}
					})
				}
				
			})
			
		},
		// 分布分项选择
		optionTreeSelect(e) {
			if (e && e.length > 0) {
				this.form.optionId = e[0].id
				this.form.optionName = e[0].label
			}
		},
		// 分布分项取消选择
		optionTreeCancel(e) {
			this.form.optionId = ''
			this.form.optionName = '请选择'
		},
		// 责任人选择
		personTreeSelect(e) {
			this.form.users = []
			if (e && e.length > 0) {
				e.forEach(item=>{
					this.form.users.push({
						userId: item.id,
						userName: item.label
					})
				})
			}
	
		},
		// 责任人取消选择
		personTreeCancel(e) {
			this.form.liables = []
		},
		// 抄送人选择
		copyTreeSelect(e) {
			this.form.cces = []
			if (e && e.length > 0) {
				e.forEach(item=>{
					this.form.cces.push({
						userId: item.id,
						userName: item.label
					})
				})
			}
		},
		// 抄送人取消选择
		copyTreeCancel(e) {
			this.form.cces = []
		},
		// 组织树选择
		deptTreeSelect(e) {
			if (e && e.length > 0) {
				this.form.companyId = e[0].id
				this.form.subcontract = e[0].label
			}
		},
		// 组织树取消选择
		deptTreeCancel(e) {
			this.form.companyId = ''
			this.form.subcontract = '请选择'
		},
		//处理图片文件数据
		handleImgFile(data){
			return data.map(res=>{
				return {id:res.fileID}
			})
		},
		//处理责任人数据
		handleUser(data){
			return data.map(res=>{
				return res.userId
			})
		},
		// 保存
    save(e) {
			this.$refs['form'].validate().then(res=>{
				if(this.form.users.length>0){
					if(this.pageStatus=='0'){
						addCheck({
							pics:this.handleImgFile(this.form.pics),
							locationName:this.form.locationName,
							troubleLevel:this.form.troubleLevel,
							troubleDesc:this.form.troubleDesc,
							deadline:this.form.deadline,
							users:this.handleUser(this.form.users),
							measure:this.form.measure,
							files:this.handleImgFile(this.form.files),
							status:e
						}).then(res=>{
							if(res.code==200){
								uni.showToast({
									title:'添加成功'
								})
								uni.redirectTo({
									url:'./index'
								})
								// uni.navigateTo({
								// 	url:'./index'
								// })
							}else{
								uni.showToast({
									title:res.msg,
									icon:'error'
								})
							}
						})
					}else if(this.pageStatus=='1'){
						updateCheck({
							id:this.form.id,
							pics:this.handleImgFile(this.form.pics),
							locationName:this.form.locationName,
							troubleLevel:this.form.troubleLevel,
							troubleDesc:this.form.troubleDesc,
							deadline:this.form.deadline,
							users:this.handleUser(this.form.users),
							measure:this.form.measure,
							files:this.handleImgFile(this.form.files),
							status:e
						}).then(res=>{
							if(res.code==200){
								uni.showToast({
									title:'修改成功'
								})
								uni.redirectTo({
									url:'./index'
								})
								// uni.navigateTo({
								// 	url:'./index'
								// })
							}else{
								uni.showToast({
									title:res.msg,
									icon:'error'
								})
							}
						})
					}
				}else{
					uni.showToast({
						title:'请选择责任人',
						icon:'error'
					})
				}
				
				
				
			});
		}
  }
}
</script>
<style lang="scss" scoped>
	#hinde{
		::v-deep .file-picker__box{
			display: none!important;
		}
	}
	.detail{
		::v-deep .is-add{
			display: none!important;
		}
	}
	
	.radio{
		::v-deep .uni-forms-item__box{
			border-bottom: 0.51rpx solid #d4d4d4;
		}
		::v-deep .uni-forms-item__content{
			line-height: 65.69rpx;
		}
	}
	.uni-label-pointer{
		margin-right: 27.37rpx;
		::v-deep .uni-radio-input{
			width: 27.37rpx;
			height: 27.37rpx;
		}
	}
	.fileList{
		width: 80%;
	}
	.fileItem{
		margin-bottom: 18.24rpx;
		padding-right: 18.24rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 63.86rpx;
		width: 100%;
		border-bottom: 1.82rpx solid #dedede;
		// background-color: #f1f1f1;
		text{
			overflow: hidden;
			text-overflow:ellipsis;
			white-space: nowrap;
		}
	}
	.upbtn{
		margin-top: 9.12rpx;
	}
   ::v-deep	.is-disabled{
		background-color: #ffffff !important;
	}
	.title{
		margin-top: 27.37rpx;
		padding-left: 18.24rpx;
		font-size: 27.37rpx;
		font-weight: bold;
	}
	.tables{
		margin-top: 9.12rpx;
		padding: 0rpx 18.24rpx;
		image{
			width: 80rpx;
			height: 80rpx;
		}
	}
	.handleBtns{
		padding-bottom: 36.49rpx;
		margin-top: 36.49rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	#materialEdit {
		min-height: 100vh;
		background-color: #fafafa;
		
		.nav-box {
			width: 100vw;
			height: 160px;
			margin-top: -44px;
			padding: 56px 20px 56px 20px;
			background-image: url(../../static/img/home/head-bg.png);
			
			.nav-box-text {
				height: 50px;
				display: flex;
				align-items: center;
				
				.person {
					width: 48px;
					height: 48px;
				}
				.welcome {
					color: #333;
					font-size: 32rpx;
					margin-left: 40rpx;
				}
			}
		}
		
		.project {
			padding: 10px;
			border-radius: 8px;
			background-color: #fff;
			margin: -32px 20px 0 20px;
			box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, .1);
			
			text {
				font-size: 14px;
				font-weight: 700;
			}
		}
		
		.uni-list {
			background-color: #fff;
			margin: 10px 20px 0 20px;
			box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, .1);
			
			/deep/ .uni-forms-item__inner {
				padding: 0 10px;
				border-bottom: 1rpx solid #bfbfbf;
			}
			/deep/ .uni-list-item__container {
				border-bottom: 1rpx solid #bfbfbf;
			}
			/deep/ .uni-error-message {
				right: 0;
				left: auto;
				margin-right: 5px;
			}
			/deep/ .uni-date__x-input {
				height: 36px;
				line-height: 36px;
			}
			/deep/ .uni-group {
				margin-top: 0!important;
			}
			/deep/ .uni-list-item__container {
				padding: 8px 10px;
			}
			/deep/ .uni-group__content {
				padding: 5px 0 5px 10px;
			}
			/deep/ .uni-data-checklist {
				margin-top: 0!important;
			}
			/deep/ .checklist-box {
				margin-right: 10px;
			}
			/deep/ .uni-forms-item__label {
				height: auto;
				line-height: 24px;
				align-items: baseline;
			}
			/deep/ .icon-add {
				width: 30px;
			}
			.is-required {
				color: #f00;
				font-weight: bold;
			}
			.slot-box {
				color: #333;
				width: 70px;
				font-size: 14px;
			}
			.tree-select {
				flex: 1;
				color: grey;
				font-size: 14px;
			}
			.uni-forms-item {
				
				&:last-child {
					/deep/ .uni-forms-item__inner {
						border-bottom: 0;
					}
				}
			}
		}
		
		.bottom-nav {
			display: flex;
			align-items: center;
			left: 0;
			bottom: 0;
			width: 100vw;
			height: 50px;
			padding: 10px;
			position: fixed;
			background-color: #fff;
			box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, .1);
		}
	}
</style>
